package org.example.com.atguigu.contorller;

import io.swagger.v3.oas.annotations.Operation;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.example.com.atguigu.assistant.XiaoHuaAgent;
import org.example.com.atguigu.bean.ChatForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@Slf4j
@Tag(name = "小花")
@RestController
@RequestMapping("/xiaohua")
public class XiaoHuaController {
    @Autowired
    private XiaoHuaAgent xiaoHuaAgent;

    @Operation(summary = "对话")
    @PostMapping(value = "/chat",produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm){ // 使用正确的 @RequestBody 注解
        log.info("ss", chatForm);
        Flux<String> chat = xiaoHuaAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
        return chat;
    }
}
